package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TAccountDetail;
import com.ruoyi.system.service.ITAccountDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 示账户变更的明细记录Controller
 * 
 * @author ruoyi
 * @date 2022-03-17
 */
@RestController
@RequestMapping("/system/accountDetail")
public class TAccountDetailController extends BaseController
{
    @Autowired
    private ITAccountDetailService tAccountDetailService;

    /**
     * 查询示账户变更的明细记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TAccountDetail tAccountDetail)
    {
        if(tAccountDetail.getTransactionDate1()!=null){
            tAccountDetail.setTD1(tAccountDetail.getTransactionDate1()[0]);
            tAccountDetail.setTD2(tAccountDetail.getTransactionDate1()[1]);
        }
        startPage();
        List<TAccountDetail> list = tAccountDetailService.selectTAccountDetailList(tAccountDetail);
        return getDataTable(list);
    }

    /**
     * 导出示账户变更的明细记录列表
     */
    @Log(title = "示账户变更的明细记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAccountDetail tAccountDetail)
    {
        List<TAccountDetail> list = tAccountDetailService.selectTAccountDetailList(tAccountDetail);
        ExcelUtil<TAccountDetail> util = new ExcelUtil<TAccountDetail>(TAccountDetail.class);
        util.exportExcel(response, list, "示账户变更的明细记录数据");
    }

    /**
     * 获取示账户变更的明细记录详细信息
     */
    @GetMapping(value = "/{aid}")
    public AjaxResult getInfo(@PathVariable("aid") Long aid)
    {
        return AjaxResult.success(tAccountDetailService.selectTAccountDetailByAid(aid));
    }

    /**
     * 新增示账户变更的明细记录
     */
    @Log(title = "示账户变更的明细记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add1(@RequestBody TAccountDetail tAccountDetail)
    {
        return toAjax(tAccountDetailService.insertTAccountDetail(tAccountDetail));
    }

    /**
     * 修改示账户变更的明细记录
     */
    @Log(title = "示账户变更的明细记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAccountDetail tAccountDetail)
    {
        return toAjax(tAccountDetailService.updateTAccountDetail(tAccountDetail));
    }

    /**
     * 删除示账户变更的明细记录
     */
    @Log(title = "示账户变更的明细记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{aids}")
    public AjaxResult remove(@PathVariable Long[] aids)
    {
        return toAjax(tAccountDetailService.deleteTAccountDetailByAids(aids));
    }
}
